<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>基础数据管理-日历列表</title>
    <script src="/scripts/boot.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:hidden;
            background: #ffffff;
        }
        body{
        	background: #ffffff!important;
            padding:20px;
        }
        .mini-tab{
            background: #ffffff;
            border: 1px solid #ffffff;
        }
        .mini-tabs-space,.mini-tabs-space2{
            border-bottom: solid 1px #ffffff;
        }
        .mini-tabs-plain .mini-tab-text{
            line-height: 32px;
        }
        .mini-tab-active{
            position: relative;
            color: #02ccc3;
            font-family: '微软雅黑';
        }
        .mini-tab-active:after {
            content: "";
            position: absolute;
            width: 100%;
            height: 2px;
            left: 0;
            bottom: -2px;
            background: #02ccc3;
        }
        .mini-tabs-header{
            border-bottom: 1px solid #edf0f7;
        }
        .mini-tabs-scrollCt{
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<!--<div class="position-rel">-->
    <!--<div class="position-abs">-->
        <!--<a class="add-botton" id="add-btn"><span class="add-bg"></span>新增</a>-->
    <!--</div>-->
<!--</div>-->
<div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;" bodyStyle="padding:0;border:0;">
    <div title="工作日">
        <div class="container">
            <div class="mini-clearfix mb-10">
                <div class="mini-col-6 mini-col-sm-3">
                    <a class="plan-btn mR-20"  onclick="list.gridWork.newOrEdit('new')"><span class="add-bg"></span>新增</a>
                </div>
            </div>
        </div>
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:90%;"  url="/workCalender/listByPage" sizeList="[5,10,20,50]" pageSize="20" idField="user_id" multiSelect="true"></div>
    </div>
    <div title="非工作日">
        <div class="container">
            <div class="mini-clearfix mb-10">
                <div class="mini-col-6 mini-col-sm-3">
                    <a class="plan-btn mR-20"  onclick="list.gridRest.newOrEdit('new')"><span class="add-bg"></span>新增</a>
                </div>
            </div>
        </div>
        <div id="datagrid2" class="mini-datagrid" style="width:100%;height:90%;"  url="/workCalender/listByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="true"></div>
    </div>
</div>
<!--<div class="tab">-->
        <!--<div class="tab-menu">-->
            <!--<ul>-->
                <!--<li class="change">工作日</li>-->
                <!--<li>非工作日</li>-->
                <!--<div class="position-rel">-->
	                 <!--<div class="position-abs">-->
	                     <!--<a class="add-botton" id="add-btn"><span class="add-bg"></span>新增</a>-->
	                 <!--</div>-->
             	<!--</div>-->
            <!--</ul>-->
        <!--</div>-->
        <!--<div class="tab-box">-->
            <!--<div class="div_chose">-->
            	<!--&lt;!&ndash;<div class="mini-fit">&ndash;&gt;-->
				    <!--<div id="datagrid1" class="mini-datagrid" style="width:100%;height:95%;"  url="/workCalender/listByPage" sizeList="[5,10,20,50]" pageSize="20" idField="user_id" multiSelect="true">-->
				        <!--&lt;!&ndash; <div property="columns">-->
				            <!--<div type="checkcolumn" headerAlign="center" align="center"></div>-->
				            <!--<div type="indexcolumn" headerAlign="center" align="center">序号</div>-->
				            <!--<div field="typeCoding" width="120" headerAlign="center" allowSort="true">开始日期</div>-->
				            <!--<div field="typeName" width="120" headerAlign="center" allowSort="true">结束日期</div>-->
				            <!--<div field="createName" width="120" headerAlign="center" allowSort="true">说明</div>-->
				            <!--<div name="action" width="200" headerAlign="center" align="center">操作</div>-->
				        <!--</div> &ndash;&gt;-->
				    <!--</div>-->
				<!--&lt;!&ndash;</div>&ndash;&gt;-->
            <!--</div>-->
            <!--<div class="div_chose">-->
            	<!--&lt;!&ndash;<div class="mini-fit">&ndash;&gt;-->
				    <!--<div id="datagrid2" class="mini-datagrid" style="width:100%;height:95%;"  url="/workCalender/listByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="true">-->
				        <!---->
				    <!--</div>-->
				<!--&lt;!&ndash;</div>&ndash;&gt;-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<script type="text/javascript">
    var grid,gridbreak;
    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            grid = mini.get("datagrid1");
            gridbreak = mini.get("datagrid2");
            list.gridWork.grid();
            list.gridRest.grid();
        },
        gridWork:{
        	grid: function(){
            	grid.set({
                    columns: [
                        { type: "indexcolumn", header: "编号",headerAlign: "center"},
                        { field: "editDate", width: 120, headerAlign: "center", align:"center", allowSort: true, header: "工作日",dateFormat:"yyyy-MM-dd",renderer:"ondayRenderer"},
                        { field: "remark", width: 100, headerAlign: "center", allowSort: true, header: "说明"},
                        { name:"action", width:100, headerAlign:"center", align:"center", header: "操作"}
                    ]
                });
            	grid.load({type: 1});
                grid.on("drawcell", function (e) {
                    var column = e.column;
                    var record = e.record;
                    if (column.name == "action") {
                        e.cellHtml = '<a class="revise-botton" href="javascript:list.gridWork.newOrEdit(\''+'edit'+'\')">编辑</a><a class="check-botton btn-bd" href="javascript:list.gridWork.view()">查看</a><a class="del-botton btn-bd" onclick="list.gridWork.remove()">删除</a>';
                    }
                });
            },
            //    新增或编辑
            newOrEdit: function (opt) {
                mini.open({
                    url: "/dataBase/kalendar/new.html",
                    title: "编辑工作日设置", width: 1000, height: 360,
                    onload: function () {
                    	if(opt=="edit"){
                    		var row = grid.getSelected();
                   		    var data = {"id": row.id,"type":1,"state":opt};
                    	}else{
                    		 var data = {"state":opt,"type":1};
                    	}
                        var iframe = this.getIFrameEl();
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
            },
            //    查看
            view: function(){
                var row = grid.getSelected();
                if (row) {
                    mini.open({
                        url: "/dataBase/kalendar/view.html",
                        title: "查看工作日设置", width: 1000, height: 360,
                        onload: function () {
                            var iframe = this.getIFrameEl();
                            var data = {"id": row.id,"type":1};
                            iframe.contentWindow.view.SetData(data);
                        },
                        ondestroy: function (action) {
                            grid.reload();
                        }
                    });

                } else {
                    alert("请选中一条记录");
                }
            },
            //    删除
            remove: function () {
                var row = grid.getSelected();
                if (row) {
                    mini.confirm("确定删除选中记录？","确定",function (action) {
                        if(action=="ok"){
                            $.ajax({
                                url: "/workCalender/del?id=" + row.id,
                                type : "post",
                                success: function (text) {
                                    if (text.state) {
                                        grid.reload();
                                        common.prompt("删除成功");
                                    } else {
                                        common.prompt(text.message);
                                    }
                                },
                                error:function (text) {
                                    common.prompt(text.message);
                                }
                            });
                        }
                    });
                } else {
                    alert("请选中一条记录");
                }
            }
        },
        gridRest:{
        	grid: function(){
        		gridbreak.set({
                    columns: [
                        { type: "indexcolumn", header: "编号" },
                        { field: "editDate", width: 120, headerAlign: "center", allowSort: true, header: "非工作日",dateFormat:"yyyy-MM-dd",renderer:"ondayRenderer"},
                        { field: "remark", width: 100, headerAlign: "center", allowSort: true, header: "说明"},
                        { name: "action", width: 100, headerAlign: "center", allowSort: true, align:"center", header: "操作"}
                    ]
                });
        		gridbreak.load({type: 2});
        		gridbreak.on("drawcell", function (e) {
                    var column = e.column;
                    var record = e.record;
                    if (column.name == "action") {
                        e.cellHtml = '<a class="revise-botton" href="javascript:list.gridRest.newOrEdit(\''+'edit'+'\')">编辑</a><a class="check-botton btn-bd" href="javascript:list.gridRest.view()">查看</a><a class="del-botton btn-bd" onclick="list.gridRest.remove()">删除</a>';
                    }
                })
            },
            //    新增或编辑
            newOrEdit: function (opt) {
                mini.open({
                    url: "/dataBase/kalendar/new.html",
                    title: "编辑非工作日设置", width: 1000, height: 360,
                    onload: function () {
                    	if(opt=="edit"){
                    		var row = gridbreak.getSelected();
                   		    var data = {"id": row.id,"type":2,"state":opt};
                    	}else{
                    		 var data = {"state":opt,"type":2};
                    	}
                        var iframe = this.getIFrameEl();
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                    	gridbreak.reload();
                    }
                });
            },
            //    查看
            view: function(){
                var row = gridbreak.getSelected();
                if (row) {
                    mini.open({
                        url: "/dataBase/kalendar/view.html",
                        title: "查看非工作日设置", width: 1000, height: 360,
                        onload: function () {
                            var iframe = this.getIFrameEl();
                            var data = {"id": row.id,"type":2,};
                            iframe.contentWindow.view.SetData(data);
                        },
                        ondestroy: function (action) {
                        	gridbreak.reload();
                        }
                    });

                } else {
                    alert("请选中一条记录");
                }
            },
            //    删除
            remove: function () {
                var row = gridbreak.getSelected();
                if (row) {
                    mini.confirm("确定删除选中记录？","确定",function (action) {
                        if(action=="ok"){
                            $.ajax({
                                url: "/workCalender/del?id=" + row.id,
                                success: function (text) {
                                    if (text.state) {
                                        common.prompt("删除成功");
                                        gridbreak.reload();
                                    } else {
                                        common.prompt(text.message);
                                    }
                                },
                                error:function (text) {
                                    common.prompt(text.message);
                                }
                            });
                        }
                    });
                } else {
                    alert("请选中一条记录");
                }
            }
        }
    };
    list.init();
    // var _index=0;
    ///////////////////////////////////////////////////////////////
    // $(".tab-menu li").on('click',function(){
    //     //通过 .index()方法获取元素下标，从0开始，赋值给某个变量
    //       _index = $(this).index();
    //     //让内容框的第 _index 个显示出来，其他的被隐藏
    //        $(".tab-box>div").eq(_index).show().siblings().hide();
    //     //改变选中时候的选项框的样式，移除其他几个选项的样式
    //     $(this).addClass("change").siblings().removeClass("change");
    //     if(_index==0){
    //         list.gridWork.grid();
    //     }else{
    //         list.gridRest.grid();
    //     }
    // });
    // $("#add-btn").on('click',function(){
    // 	if(_index==0){
    //     	list.gridWork.newOrEdit('new')
    //     }else{
    //     	list.gridRest.newOrEdit('new')
    //     }
    // });
</script>
</body>
</html>
